import serial
import pygame

ser = serial.Serial("com4")

TIMES = 100
pygame.init()
beginTime = pygame.time.get_ticks()


ser.flushInput()
for i in xrange(TIMES):
    ser.readline()
ser.close()

endTime = pygame.time.get_ticks()
deltaT = endTime - beginTime
if deltaT > 0:
    freq = float(TIMES)*1000 / deltaT
else:
    freq = 10E10

print 'received %d lines used %d seconds'%(TIMES, deltaT/1000)
print 'frequency: %f Hz'%(freq)

